﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Restaurant.DTO;
using Restaurant.DAO;

namespace Restaurant.BUS
{
    public class LoaiNguyenLieuService
    {
        private LoaiNguyenLieuDB httDAO = new LoaiNguyenLieuDB();

        public DataTable LoadLoaiNguyenLieu()
        {
            return httDAO.LayLoaiNguyenLieu();
        }

        public string LayLoaiNguyenLieuLieuTheoMa(int ma)
        {
            DataTable dbtab = httDAO.LayLoaiNguyenLieuTheoMa(ma);
            DataRow dbrow = dbtab.Rows[0];
            return dbrow[1].ToString();
        }

        public DataTable LoadDonViTinh()
        {
            return httDAO.LayDonViTinh();
        }

        public string LayDonViTinhTheoMa(int ma)
        {
            DataTable dbtab = httDAO.LayDonViTinhTheoMa(ma);
            DataRow dbrow = dbtab.Rows[0];
            return dbrow[1].ToString();
        }

        public bool ThemLoaiNguyenLieu(string LoaiNL)
        {
            if (LoaiNL == "")
            {
                return false;
            }
            if (httDAO.ThemLoaiNguyenLieu(LoaiNL))
                return true;
            return false;
        }

        public bool ThemDonViTinh(string DVTinh)
        {
            if (DVTinh == "")
            {
                return false;
            }
            if (httDAO.ThemDonViTinh(DVTinh))
                return true;
            return false;
        }

        public bool XoaLoaiNguyenLieu(int maLoaiNL)
        {
            if (httDAO.XoaLoaiNguyenLieu(maLoaiNL))
                return true;
            return false;
        }

        public bool XoaDonViTinh(int maDVTinh)
        {
            if (httDAO.XoaDonViTinh(maDVTinh))
                return true;
            return false;
        }

        public bool SuaLoaiNguyenLieu(int maLoaiNL, string tenLoaiNL)
        {
            if (httDAO.SuaLoaiNguyenLieu(maLoaiNL,tenLoaiNL))
                return true;
            return false;
        }

        public bool SuaDonViTinh(int ma, string ten)
        {
            if (httDAO.SuaDonViTinh(ma,ten))
                return true;
            return false;
        }
    }
}
